package bairui.international.console.web.controller.barter.category.product;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.ResponseBody;

import com.lianjing.sh.spring.web.controller.base.action.Action;
import com.lianjing.sh.spring.web.controller.enhance.output.FomatOutput;

import bairui.international.model.domain.jpa.TB_ProductRollImage;
import bairui.international.service.Service_ProductRollImage;

/**
 *
 * 产品滚动图片添加
 *
 * @generated
 * 
 * @see STest_C_Barter_Category_ProductRollUpload_Page 测试
 *
 */
@Controller
public class C_Barter_Category_ProductRollUpload_Page
 extends SC_Barter_Category_ProductRollUpload_Page 
{
	
	@Autowired private Service_ProductRollImage service_ProductRollImage;
	
	/**
	 * 分页列表
	 */
	@Action(Page.class)
	@GetMapping(value=Page.RequestMappingValue, consumes=MediaType.APPLICATION_JSON_VALUE)
	public @FomatOutput @ResponseBody Object page(
		HttpServletRequest request, 
		@PathVariable(name=Page.PathVariableName.CategoryId) long categoryId, 
		@PathVariable(name=Page.PathVariableName.Id) long id
	) throws Exception {
		org.springframework.data.domain.Page<TB_ProductRollImage> page = service_ProductRollImage.page(
				it->Page.Filter.query(it, request)
					.and(it.product.id.eq(id)), 
				Page.Output.page(request), 
				it->Page.Output.sort(it, request)
			);
		page.forEach(it->{
			it.setFileUrl(C_Barter_Category_ProductRollUpload_ShowImg.ShowImg.Operate(categoryId, id, it.getId()).getUrl());
		});
		//
		return Page.Output.output(
				page
			);
	}
	

}
